/* carrousel */
var Carrousel = new Class({
	initialize: function(carrousel){
		this.carrousel = $(carrousel);
		this.aLis = this.carrousel.getElement("ul").getElements("li");
		this.anchor = this.aLis.getElement("a");
		this.img = this.anchor.getElement("img.mobile");
		this.legende = this.carrousel.getElement("div.legende");
		this.cursor = this.legende.getElement("div.curseur");
		
		this.carrousel.getParent(".line").adopt(new Element('div', {"id": "iphoneSeparator"}));
		$("iphoneSeparator").setStyle("left", this.carrousel.getParent(".line").getFirst().offsetWidth + 8);
		
		var _self = this;
		
		this.anchor.addEvent("mouseover", function(e){
			var position = this.getProperty("class").substring(4);
			var imgAlt= this.getElement("img.mobile").getProperty("alt");
			console.log(imgAlt);
			var telName = imgAlt.substring(0,imgAlt.lastIndexOf("|")+1);
			var telPrice = imgAlt.substring(imgAlt.lastIndexOf("|")+1);
			
			if(position < 65){
				_self.cursor.removeClass("curseurWhite");
				_self.cursor.addClass("curseurDark");
			}else{
				_self.cursor.removeClass("curseurDark");
				_self.cursor.addClass("curseurWhite");
			}
			
			_self.cursor.setStyle("backgroundPosition",position+"px top");
			_self.legende.getElement("div.telName").set("html",telName);
			_self.legende.getElement("div.telPrice").set("html",telPrice);
		});
	}
});
Moodule.register("Carrousel", "div.carrousel");
